<?php
/**
 * Created by PhpStorm.
 * User: wenQing
 * Date: 2016/8/29
 * Time: 14:54
 */
namespace App\Server;

use anlutro\cURL\cURL;

class Helper
{
    /**
     * 发送post请求
     * @param string $url 请求地址
     * @param array $post_data post键值对数据
     * @return string
     */
    public static function send_post($url, $post_data)
    {
        $curl = new cURL();
        $result = $curl->post($url,$post_data);

        return \GuzzleHttp\json_decode($result->body,true);
    }

    /**
     * 检测并返回用户id
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
     * create by wenQing
     */
    public static function getUserId()
    {
        $value = \Session::get('user.u_id');
        if(empty($value))
            return view('user');
        return $value;
    }

    /**
     * 刷新界面
     * create by wenQing
     */
    public static function reflash()
    {
        echo"<script>location.href='/';</script>";
    }
}